package com.alex.bootwar.controller;

import com.alex.bootwar.service.UserService;
import com.alex.bootwar.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Value("${alex.war.test}")
    private String test;

    @GetMapping("/test")
    public String test(){
        return test;
    }

    @Autowired
    private UserService userService;

    @GetMapping("/findById/{id}")
    public Object findById(@PathVariable("id") Integer id) {
        return userService.getById(id);
    }

    @RequestMapping("/createUser")
    public Object createUser(User user){
        System.out.println(user);
        return "success";
    }
}
